Module TV3D_Main
    'This module wase made by Raymond Ellis

    'This module has most of the needed TV3D stuff in it.

    Public Globals As New TVGlobals

    'Rendering.
    Public TV As TVEngine 'The main engine.
    Public Scene As TVScene 'The scene.
    Public LightEngine As TVLightEngine 'Light engine.
    Public Scr2D As TVScreen2DImmediate '2D stuff.
    Public ScrText As TVScreen2DText 'Text.

    Public Const scrWidth As Short = 800 '1024
    Public Const scrHeight As Short = 600 '768
   

    'Factorys.
    Public Tex As TVTextureFactory 'Textures.
    Public Mat As TVMaterialFactory 'Materials.

    'Misc
    Public Camera As TVCamera
    Public Inp As TVInputEngine

    Public Math As TVMathLibrary 'Math.



    Public Sub SetupTV3Dbasic(Optional ByVal formHandle As Integer = -1)


        'Setup the main engine.
        TV = New TVEngine
        TV.SetDebugFile("Debug.txt") 'Set the debugfile.
        'Start in windowed.
        TV.Init3DWindowed(formHandle)

        'Setup misc stuff.
        Scene = New TVScene 'Scene.

        ScrText = New TVScreen2DText 'Text.

    End Sub
    Public Sub SetupTV3Drest()
        TV.DisplayFPS(True) 'Display the FPS.
        TV.SetAngleSystem(CONST_TV_ANGLE.TV_ANGLE_DEGREE) 'Set the angle system.

        Scr2D = New TVScreen2DImmediate '2D stuff.
        Inp = New TVInputEngine 'Input
        Inp.Initialize() 'Initialize the input.

        'Setup the texture factory.
        Tex = New TVTextureFactory
        Tex.SetTextureMode(CONST_TV_TEXTUREMODE.TV_TEXTUREMODE_BETTER)

        'Setup the meterial factory.
        Mat = New TVMaterialFactory

        Math = New TVMathLibrary 'Math.

    End Sub

  

    ''' <summary>
    ''' Vector 3D
    ''' </summary>
    ''' <param name="x">Position X</param>
    ''' <param name="y">Position Y</param>
    ''' <param name="z">Position Z</param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function Vector3(ByVal x As Single, ByVal y As Single, ByVal z As Single) As TV_3DVECTOR
        Return Globals.Vector3(x, y, z)
    End Function
    ''' <summary>
    ''' Vector 2D
    ''' </summary>
    ''' <param name="x">Position X</param>
    ''' <param name="y">Position Y</param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function Vector2(ByVal x As Single, ByVal y As Single) As TV_2DVECTOR
        Return Globals.Vector2(x, y)
    End Function

    ''' <summary>
    ''' Color from 0 to 1.
    ''' </summary>
    ''' <param name="r">Red</param>
    ''' <param name="g">Green</param>
    ''' <param name="b">Blue</param>
    ''' <param name="a">Alpha</param>
    Public Function RGBA(ByVal r As Single, ByVal g As Single, ByVal b As Single, ByVal a As Single) As Integer
        Return Globals.RGBA(r, g, b, a)
    End Function

    Public Function GrgbA(ByVal Gray As Single, ByVal a As Single) As Integer
        Return Globals.RGBA(Gray, Gray, Gray, a)
    End Function

    ''' <summary>
    ''' Color from 0 to 256.
    ''' </summary>
    ''' <param name="r">Red</param>
    ''' <param name="g">Green</param>
    ''' <param name="b">Blue</param>
    ''' <param name="a">Alpha</param>
    Public Function RGBA256(ByVal r As Integer, ByVal g As Integer, ByVal b As Integer, ByVal a As Integer) As Integer
        Return Globals.RGBA256(r, g, b, a)
    End Function

    ''' <summary>
    ''' I don't know what TV color is but it is here..
    ''' </summary>
    ''' <param name="r">Red</param>
    ''' <param name="g">Green</param>
    ''' <param name="b">Blue</param>
    ''' <param name="a">Alpha</param>
    Public Function TVColor(ByVal r As Single, ByVal g As Single, ByVal b As Single, ByVal a As Single) As TV_COLOR
        Return Globals.TVColor(r, g, b, a)
    End Function



    ''' <summary>
    ''' Get the texture from name.
    ''' </summary>
    ''' <param name="Name">Name of texture.</param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function GetTex(ByVal Name As String) As Integer
        Return Globals.GetTex(Name)
    End Function
    ''' <summary>
    ''' Gets the materil from name.
    ''' </summary>
    ''' <param name="MaterilName">The name of the materil.</param>
    ''' <returns></returns>
    ''' <remarks></remarks>
    Public Function GetMat(ByVal MaterilName As String) As Integer
        Return Globals.GetMat(MaterilName)
    End Function

End Module
